export const getRandomString = (n, format = 'def') => {
	// format类型 all -> 全部(含大小写)，f -> 16进制，def=全部(小写)
	 n = parseFloat(n);
	if (!n) {
		throw new Error('getRandomString方法的参数必须是大于0的数字 ')
	}
	let chars = 'abcdefghijklmnopqrstuvwxyz0123456789'
	switch (format) {
		case 'all':
			chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
			break
		case 'f':
			chars = 'abcdef0123456789';
			break
		default:;
	}
	// const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
	const maxPos = chars.length;
	let str = '';
	for (let i = 0; i < n; i++) {
		str += chars.charAt(Math.floor(Math.random() * maxPos));
	}
	return str;
}